package day05;

import java.util.Scanner;
import java.util.Arrays;

public class Practice {
    public static void main(String[] args) {

       /*int score = 0;
        for (int i = 0; i < 10; i++) {
            int a1 = (int) (Math.random() * 50);
            int a2 = (int) (Math.random() * 50);
            int result = a1 + a2;
            System.out.println(a1 + "+" + a2);
            Scanner scan = new Scanner(System.in);
            int answer = scan.nextInt();
            if (answer == result) {
                System.out.println("恭喜你答对了");
                score += 10;
            } else {
                System.out.println("很遗憾打错了哦");
            }
        }
        System.out.println("最后得分是" + score);*///随机加法运算器


       /*for (int i = 1; i <=9 ; i++) {//控制行
           for (int j = 1; j <=i ; j++) {//控制列
               System.out.print(j+"x"+i+"="+j*i+"\t");
           }
           System.out.println();
       }*///九九乘法表


        /*int[] a1 = new int[10];
        int[] a = {1, 2, 3, 4};
        int[] a2 = new int[]{1, 2, 3, 4, 5, 5, 6};
        int[] a3;
        //a3 = {5,6,9,8,7};//错误编译,此方式只能声明同时初始化
        a3 = new int[]{9, 8, 7, 4, 5, 1};      */ //数组小代码练习：声明以及初始化

        /*int[] arr = {5, 6, 2, 1, 3, 4, 8, 7, 10};
        System.out.println(arr.length);//输出数组的长度
        System.out.println(arr[arr.length-1]);//输出数组的最后一个数
        int[] arrr = new int[5];
        arrr[5] = 100;//ArrayIndexOutOfBoundsException数组下标越界异常*///数组小代码练习：访问

        /*int arr[] = new int[10];
        for (int i = 0; i < arr.length; i++) {//遍历arr的数组
            arr[i] = (int) (Math.random() * 100);
            System.out.print(arr[i]+"\t");
        }
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
        }
        System.out.println();
        System.out.println("最大值是:" + max);
        System.out.println();
        System.out.println("按照从小到大的顺序排列");
        Arrays.sort(arr);
        for (int i = 0; i < arr.length ; i++) {
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
        System.out.println("倒着输出是");
        for (int i = arr.length-1; i >=0 ; i--) {
            System.out.print(arr[i]+"\t");
        }
*///遍历数组,并求出数组的最大值,在将数组进行升序排列,然后将数组进行倒叙输出


    }
}
